package com.example.myapplication.chap01;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.example.myapplication.R;

public class LoginActivity extends AppCompatActivity {

    private EditText txtUsername = null;
    private EditText txtPassword = null;
    private Button btnLogin = null;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_01_login);
        txtUsername = findViewById(R.id.et_account);
        txtPassword = findViewById(R.id.et_pwd);
        btnLogin = findViewById(R.id.btn_login);
        btnLogin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(LoginActivity.this,"物联网",Toast.LENGTH_LONG).show();
                String account = txtUsername.getText().toString().trim();
                String pwd = txtPassword.getText().toString().trim();

                AlertDialog.Builder dialog = new AlertDialog.Builder(LoginActivity.this);
                dialog.setTitle("登录");
                dialog.setMessage("用户名："+ account + ""+ "密码："+pwd);
                dialog.create().show();
            }
        });

    }
}